﻿using System;
using System.Linq;

namespace Problem004
{
    class Program
    {
        private static readonly Func<string, bool> isPalindrome = x => x.Equals(new string(x.Reverse().ToArray()));

        static void Main()
        {
            var allProducts = from x in Enumerable.Range(100, 900)
                              from y in Enumerable.Range(100, 900)
                              where x <= y
                              let product = x * y
                              where isPalindrome(product.ToString())
                              orderby product ascending 
                              select new { x, y, product };

            foreach (var product in allProducts)
            {
                Console.WriteLine("{0} x {1} = {2}", product.x, product.y, product.product);
            }

            Console.ReadKey();
        }
    }
}
